/*
 * --------------------------------------------------------------
 * Copyright ©  2015 Hangzhou DtDream Technologies Co.,Ltd.
 * --------------------------------------------------------------
 *      Product: 协同数治
 *  Module Name: jimu
 * Date Created: 2022/11/17
 *  Description: 接口数据格式转换
 * --------------------------------------------------------------
 * Modification History
 * DATE            NAME            Description
 * --------------------------------------------------------------
 * 2022/11/17       yewj            接口数据格式转换
 * --------------------------------------------------------------
 */

package com.dtdream.jimu.config;

import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.jeecg.modules.jmreport.desreport.render.handler.convert.ApiDataConvertAdapter;
import org.springframework.stereotype.Component;

/**
 * 接口数据格式转换
 *
 * @Author: yewj
 **/
@Component("myApiDataConvertAdapter")
public class MyApiDataConvertAdapter implements ApiDataConvertAdapter {
    @Override
    public String getData(JSONObject jsonObject) {
        if(jsonObject.containsKey("data")){
            JSONArray pageList = jsonObject.getJSONArray("data");
            cn.hutool.json.JSONArray objects = JSONUtil.parseArray(pageList);
            return objects.toString();
        } else {
            return "";
        }
    }
}
